package com.pomelo.base.core.datasource;

import java.io.Serializable;
import java.util.Map;

/**
 * 数据源属性
 *
 * @author biankudingcha
 * @date: 2021-07-23
 * @since 0.5.0
 */
public class DataSourceProperty implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 数据源ID
     */
    private String dataSourceId;

    /**
     * 数据源名称
     */
    private String dataSourceName;

    /**
     * 数据库类型
     */
    private String dbType;

    /**
     * JDBC driver
     */
    private String driverClassName;

    /**
     * JDBC url 地址
     */
    private String url;

    /**
     * JDBC 用户名
     */
    private String username;

    /**
     * JDBC 密码
     */
    private String password;

    /**
     * hibernateDialect
     */
    private String hibernateDialect;

    /**
     * hibernateDefaultSchema
     */
    private String hibernateDefaultSchema;

    /**
     * hibernateHbm2ddlAuto
     */
    private String hibernateHbm2ddlAuto;

    public DataSourceProperty() {

    }

    public DataSourceProperty(Map<String, Object> data) {
        String dbId = (String) data.get("DATASOURCE_ID");
        String driverClassName = (String) data.get("DATASOURCE_DRIVER_CLASS_NAME");
        String url = (String) data.get("DATASOURCE_URL");
        String username = (String) data.get("DATASOURCE_USERNAME");
        String password = (String) data.get("DATASOURCE_PASSWORD");
        String dbType = (String) data.get("DATASOURCE_DBTYPE");
        String auto = (String) data.get("HIBERNATE_HBM2DDL_AUTO");
        String schema = (String) data.get("HIBERNATE_DEFAULT_SCHEMA");
        DataSourceProperty dataSourceProperty = new DataSourceProperty();
        dataSourceProperty.setDataSourceId(dbId);
        dataSourceProperty.setDbType(dbType);
        dataSourceProperty.setDriverClassName(driverClassName);
        dataSourceProperty.setUrl(url);
        dataSourceProperty.setUsername(username);
        dataSourceProperty.setPassword(password);
        dataSourceProperty.setHibernateHbm2ddlAuto(auto);
        dataSourceProperty.setHibernateDefaultSchema(schema);
    }

    /**
     * 获取数据源id
     *
     * @return String
     */
    public String getDataSourceId() {
        return dataSourceId;
    }

    /**
     * 设置数据源id
     *
     * @param dataSourceId 数据源id
     */
    public void setDataSourceId(String dataSourceId) {
        this.dataSourceId = dataSourceId;
    }

    /**
     * 获取数据源名称
     *
     * @return String
     */
    public String getDataSourceName() {
        return dataSourceName;
    }

    /**
     * 设置数据源名称
     *
     * @param dataSourceName 数据源名称
     */
    public void setDataSourceName(String dataSourceName) {
        this.dataSourceName = dataSourceName;
    }

    /**
     * 获取数据库类型
     *
     * @return String
     */
    public String getDbType() {
        return dbType;
    }

    /**
     * 设置数据库类型
     *
     * @param dbType 数据库类型
     */
    public void setDbType(String dbType) {
        this.dbType = dbType;
    }

    /**
     * 获取数据库连接类
     *
     * @return String
     */
    public String getDriverClassName() {
        return driverClassName;
    }

    /**
     * 设置数据库连接类
     *
     * @param driverClassName 连接类名称
     */
    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }

    /**
     * 获取数据库连接url
     *
     * @return String
     */
    public String getUrl() {
        return url;
    }

    /**
     * 设置数据库连接url
     *
     * @param url 数据库连接url
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * 获取数据库连接用户名
     *
     * @return String
     */
    public String getUsername() {
        return username;
    }

    /**
     * 设置数据库连接用户名
     *
     * @param username 数据库连接用户名
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * 获取数据库连接密码
     *
     * @return String
     */
    public String getPassword() {
        return password;
    }

    /**
     * 设置数据库连接密码
     *
     * @param password 数据库连接密码
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 获取HibernateDialect
     *
     * @return String
     */
    public String getHibernateDialect() {
        return hibernateDialect;
    }

    /**
     * 设置HibernateDialect
     *
     * @param hibernateDialect HibernateDialect
     */
    public void setHibernateDialect(String hibernateDialect) {
        this.hibernateDialect = hibernateDialect;
    }

    /**
     * 获取HibernateDefaultSchema
     *
     * @return String
     */
    public String getHibernateDefaultSchema() {
        return hibernateDefaultSchema;
    }

    /**
     * HibernateDefaultSchema
     *
     * @param hibernateDefaultSchema HibernateDefaultSchema
     */
    public void setHibernateDefaultSchema(String hibernateDefaultSchema) {
        this.hibernateDefaultSchema = hibernateDefaultSchema;
    }

    /**
     * HibernateHbm2ddlAuto
     *
     * @return String
     */
    public String getHibernateHbm2ddlAuto() {
        return hibernateHbm2ddlAuto;
    }

    /**
     * hibernateHbm2ddlAuto
     *
     * @param hibernateHbm2ddlAuto hibernateHbm2ddlAuto
     */
    public void setHibernateHbm2ddlAuto(String hibernateHbm2ddlAuto) {
        this.hibernateHbm2ddlAuto = hibernateHbm2ddlAuto;
    }

}
